The HealthActivitySummary
class provides an interface for accessing daily summaries of user activity as recorded by the Apple Health system. This includes move, exercise, and stand metrics, and optionally supports both energy-based and time-based activity move goals.
This class is useful for apps that aim to present a user's daily activity rings or generate daily fitness reports.
HealthActivitySummary
Property | Type | Description |
---|---|---|
dateComponents |
DateComponents |
Represents the calendar date associated with this activity summary. |
activityMoveMode |
HealthActivityMoveMode |
Indicates the move mode used for this summary — either active energy (activeEnergy ) or move time (appleMoveTime ). |
Each of the following methods returns a numeric value representing either the achieved metric or the goal for that metric on the specified date. All values are returned in the unit specified by the caller.
activeEnergyBurned(unit: HealthUnit): number
Returns the amount of active energy burned for the day in the given unit (e.g., kilocalories).
activeEnergyBurnedGoal(unit: HealthUnit): number
Returns the daily goal for active energy burned in the given unit.
Only valid when
activityMoveMode
isHealthActivityMoveMode.activeEnergy
.
appleMoveTime(unit: HealthUnit): number
Returns the duration of movement (in minutes or seconds) tracked by the Apple Watch's move time mode.
appleMoveTimeGoal(unit: HealthUnit): number
Returns the goal for move time on the current day.
Only valid when
activityMoveMode
isHealthActivityMoveMode.appleMoveTime
.
appleExerciseTime(unit: HealthUnit): number
Returns the total time spent in exercise (typically in minutes), as measured by the Apple Watch.
appleExerciseTimeGoal(unit: HealthUnit): number
Returns the exercise time goal for the current day.
appleStandHours(unit: HealthUnit): number
Returns the number of hours in which the user stood and moved for at least one minute.
appleStandHoursGoal(unit: HealthUnit): number
Returns the user's stand hours goal for the day (typically 12).
HealthActivitySummary
does not store historical trend data. Use multiple summaries to build a timeline.HealthUnit
must match the type of data requested. For time-based values, use HealthUnit.minute()
or HealthUnit.second()
. For count-based values like stand hours, use HealthUnit.count()
.